/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.CommunicationDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.CommunicationDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.CommunicationDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_communication.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisCommunicationDAO extends SqlMapClientDaoSupport implements CommunicationDAO {

    /**
     *  Query DB table <tt>sgw_communication</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, connect_type, protocol_type, channel_system_id, bcm_code, cert_type, gmt_create, gmt_modified from sgw_communication</tt>
     *
     *	@return List<CommunicationDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<CommunicationDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-COMMUNICATION-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>CommunicationDO</tt> object to DB table <tt>sgw_communication</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_communication(id,connect_type,protocol_type,channel_system_id,bcm_code,cert_type,gmt_create,gmt_modified) values (?, ?, ?, ?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param communication
     *	@return int
     *	@throws DataAccessException
     */
    public String insert(CommunicationDO communication) throws DataAccessException {
        if (communication == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-COMMUNICATION-INSERT", communication);

        return communication.getId();
    }

    /**
     *  Query DB table <tt>sgw_communication</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, connect_type, protocol_type, channel_system_id, bcm_code, cert_type, gmt_create, gmt_modified from sgw_communication where ((id = ?) AND (protocol_type = ?) AND (channel_system_id = ?))</tt>
     *
     *	@param id
     *	@param protocolType
     *	@param channelSystemId
     *	@return List<CommunicationDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public List<CommunicationDO> select(String id, String protocolType, String channelSystemId)
                                                                                               throws DataAccessException {
        Map param = new HashMap();

        param.put("id", id);
        param.put("protocolType", protocolType);
        param.put("channelSystemId", channelSystemId);

        return getSqlMapClientTemplate().queryForList("MS-COMMUNICATION-SELECT", param);

    }

    /**
     *  Update DB table <tt>sgw_communication</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_communication set connect_type=?, protocol_type=?, channel_system_id=?, bcm_code=?, cert_type=?, gmt_modified=sysdate where (id = ?)</tt>
     *
     *	@param connectType
     *	@param protocolType
     *	@param channelSystemId
     *	@param bcmCode
     *	@param certType
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(String connectType, String protocolType, String channelSystemId,
                      String bcmCode, String certType, String id) throws DataAccessException {
        Map param = new HashMap();

        param.put("connectType", connectType);
        param.put("protocolType", protocolType);
        param.put("channelSystemId", channelSystemId);
        param.put("bcmCode", bcmCode);
        param.put("certType", certType);
        param.put("id", id);

        return getSqlMapClientTemplate().update("MS-COMMUNICATION-UPDATE", param);
    }

    /**
     *  Delete records from DB table <tt>sgw_communication</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_communication where (id = ?)</tt>
     *
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    public int delete(String id) throws DataAccessException {
        return getSqlMapClientTemplate().delete("MS-COMMUNICATION-DELETE", id);
    }

}